"""随机生成headers"""

import random


class UserAgent:
    _explore: tuple = (
        # 'edge',  # 微软edge浏览器
        'chrome'  # 谷歌chrome浏览器
    )
    _os: tuple = (
        '(Windows NT 10.0; Win64; x64)',  # windows 10
        '(Windows NT 6.1; Win64; x64)',  # windows 7
        '(Windows NT 6.3; Win64; x64)',  # windows 8
        '(X11; Linux x86_64)',  # ubuntu 18.04
    )
    _versions: set = (
        "96.0.4639.0", "96.0.4639.2", "96.0.4640.0", "96.0.4640.2",
        "96.0.4641.0", "96.0.4641.2", "96.0.4643.0", "96.0.4642.2",
        "96.0.4644.0", "96.0.4643.2", "96.0.4645.0", "96.0.4646.0",
        "96.0.4644.3", "96.0.4645.3", "96.0.4644.2", "96.0.4646.2",
        "96.0.4647.0", "96.0.4647.2", "96.0.4648.0", "96.0.4648.2",
        "96.0.4650.0", "96.0.4649.0", "96.0.4651.0", "96.0.4650.4",
        "96.0.4652.0", "96.0.4651.2", "96.0.4652.2", "96.0.4652.3",
        "96.0.4653.0", "96.0.4653.2", "96.0.4654.0", "96.0.4654.2",
        "96.0.4655.0", "96.0.4655.4", "96.0.4656.0", "96.0.4657.0",
        "96.0.4655.7", "96.0.4656.3", "96.0.4658.0", "96.0.4656.5",
        "96.0.4655.6", "96.0.4659.0", "96.0.4658.2", "96.0.4659.2",
        "96.0.4660.0", "96.0.4660.2", "96.0.4661.0", "96.0.4660.4",
        "96.0.4660.6", "96.0.4659.3", "96.0.4662.0", "96.0.4663.0",
        "96.0.4660.11", "96.0.4662.2", "96.0.4662.5", "96.0.4663.2",
        "96.0.4664.0", "96.0.4664.2", "96.0.4662.6", "96.0.4664.4",
        "96.0.4642.0", "96.0.4664.3", "96.0.4664.9", "96.0.1043.1",
        "96.0.1050.0", "96.0.4664.18", "96.0.4664.17", "96.0.4664.27",
        "96.0.4664.35", "96.0.4664.30", "96.0.4664.42", "96.0.4664.51",
        "96.0.4664.55", "96.0.2311.135", "96.0.4670.83", "96.0.4652.192",
        "96.0.4664.97", "96.0.4664.45", "96.0.4664.92", "96.0.4657.172",
        "96.0.4672.112", "96.0.4664.104", "96.0.4652.105", "96.0.4664.93",
        "96.0.4664.116", "96.0.4664.110", "96.0.4661.54", "96.0.4664.131",
        "96.0.4639.185", "96.0.4664.137", "102.0.0.0", "103.0.0.0",
        "103.0.5060.53", "104.0.5112.101"
    )

    @property
    def random(self):
        """随机生成一个user-agent"""
        plantform = random.choice(self._os)
        version = random.choice(self._versions)  # type: ignore
        return f"Mozilla/5.0 {plantform} AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{version} Safari/537.36"  # noqa:E501


ua = UserAgent()


def get_headers() -> dict:
    user_agent = ua.random

    return {
        'User-Agent': user_agent,
        'Accept': 'application/json, text/plain, */*; q=0.01',
        'Accept-Encoding': 'gzip, deflate',
        'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
        'Content-Type': 'application/json'
    }


def get_useragent() -> str:
    return ua.random


if __name__ == '__main__':
    print(get_headers())
    print(get_useragent())
